1. The Field of the Invention
The present invention relates generally to the field of data communications and, more particularly, to communications protocols which control the flow of data from a modem to a computer.
2. The Prior State of the Art
In order to transfer digital data from a sending computer to a receiving computer a communications link must be established between the computers. In many instances the communications link is established over a telephone line. Such a communications link between computers over a telephone line is shown in FIG. 1. In FIG. 1, a receiving computer 100 communicates with a sending computer 110 to receive data over a communications link via a receiving modem (modulator/demodulator) 120. A universal asynchronous receiver transmitter (UART) 130 is provided within an I/O unit 145 within the receiving computer 100, which serves as a communications interface and buffers the data in a UART buffer 132. A sending modem 135 is employed at the sending computer 110 to encode the digital data into a signal sent over the telephone line using frequency modulation techniques. The data is then sent over the telephone line and received by the receiving modem 120 at the receiving computer 100. The receiving modem demodulates the signal to extract the digital data from the signal. The receiving modem 120 sends the digital data to the UART 130 which stores the digital data in the UART buffer 132. The UART 130 sends an interrupt to the CPU 140 to signal the arrival of the digital data. At some point thereafter, the CPU 140 obtains the digital data from the UART 130 and stores it in a communication port 156 in the memory 150 in the receiving computer via an I/O unit 145. The communications port 156 is a dedicated memory location for storing data received over the communications link.
A data transfer as described above is often initiated by an application program 152 executing on the CPU 140 in the receiving computer 100. When the CPU 140 is executing the application program 152 and encounters an instruction to read remote data which the sending computer 110 must provide, the receiving computer 100 sends an appropriate request to the sending computer 110 over the communications link. At some point thereafter, the sending computer 110 services the request and asynchronously sends the requested data back over the communications link to the UART 130. In this transaction, once the receiving computer 100 has sent the request to the sending computer 110 to send the data, the receiving computer 100 cannot predict the timing of the arrival of the data in the UART 130 because the data arrives asynchronously relative to the clock of the receiving computer 100.
Because the data transfer over the communications link is asynchronous, the receiving computer 100 must provide a mechanism to control the flow of the data to ensure that the data is obtained and processed in a timely fashion. Typically, this mechanism comprises a number of communications protocols which control the flow of the data from the UART 130. These protocols are subprograms that perform functions such as obtaining the data from the UART 130, and ensuring that the CPU 140 does not request data from the UART 130 before the data has arrived in the UART 130 or after the communications port 156 has become full. The protocols are typically implemented by the receiving computer through computer subprograms provided by the application program 152 executing on the computer which the application program 152 calls to obtain the data at some point after the data has begun to arrive in the UART 130. For example, the application program 152 performs a protocol 154 which is a subprogram that obtains the data from the UART 130.
Typically, however, the application program 152 may not call the protocols until some time after the data has begun to arrive in the UART 130. After the receiving computer 100 sends the request, there is an inherent time delay. Since it is impossible to anticipate when the data will arrive, the receiving computer 100 must then await the actual arrival of the data before continuing execution of the application program. Thus, it is desirable to devote the receiving computer 100 to other operations while awaiting for arrival of the data. Where the operating system executing on the receiving computer 100 is a multitasking system, for example, the operating system may assign other tasks to be performed by the CPU 140 of the receiving computer 100, such as executing other application programs or operating system routines. Thus, even when the receiving computer 100 receives an interrupt from the UART 130 to indicate the requested data has been received by the communications interface, the requested data cannot be obtained by the receiving computer 100 from the UART 130 until the operating system executing on the receiving computer 100 returns control of the CPU 140 to the application program 152 which requested the data. Only when so reassigned does the application program 152 execute the protocols to obtain the data from the UART 130 and provide the data to the application program.
In many computer systems, though, it is not possible for the receiving computer 100 to immediately return control of the CPU 140 to the application program 152 at the time the data is first received by the UART 130. At this time, as mentioned above, the CPU 140 receives an interrupt. This interrupt is a hardware interrupt sent over a direct line from the UART 130 to the receiving computer 100 to notify the receiving computer 100 that the data has been received. When the interrupt is received, the task currently being performed is interrupted, and an interrupt handler routine (not shown) is executed. Some current popular operating systems, however, do not allow execution of the application program 152 at this time (referred to herein as "interrupt time"). In these operating systems, the application program 152 is merely engaged to be scheduled to resume execution at some point after completion of the interrupt handler routine.
The receiving computer 100 then returns to performing the interrupted task. Then, any other tasks that already have been scheduled that have higher priority than the application program 152 are scheduled to be performed ahead of the application program 152. Only when the application program 152 is scheduled by the operating system to continue execution arc the communications protocols executed to obtain the data from the UART 130.
An example of such a current operating system is a current version of one mode of the Microsoft.RTM. Windows.TM. operating system, by Microsoft Corporation of Redmond, Wash. The Windows operating system implements a protection mechanism which protects critical code or data, such as the operating system kernel, from being altered. This mechanism does not allow an application program to access such critical code or data because an unwise or accidental alteration of the critical code or data could cause irreparable damage to the operating system. Because the interrupted task may have placed the receiving computer 100 in a state which allows alteration of the critical code or data, transferring control to the application program 152 at interrupt time would jeopardize the critical code or data because it could be altered by the application. Thus, when the CPU 140 is notified that data has been received by the UART 130, the operating system merely engages the application to be rescheduled for execution at a time during which the application program 152 can be executed without jeopardizing any critical code or data.
Unfortunately, if the application 152 is not scheduled for execution within a certain amount of time, the data sent to the receiving computer may be lost. The UART 130 stores the data in the UART buffer 132 and, as the requested data is received from the sending computer 110, awaits execution of the communications protocol 154 by the receiving computer to obtain the data. Because the size of the UART buffer 132 is limited, as new data continues to be received by the UART 130, the data stored in the UART buffer 132 will eventually be overwritten. If the application program 152 is not scheduled in time to read in the data before it is overwritten in the UART buffer 132, the requested data is lost before it can be read and utilized by the application program 152. Unfortunately an operating system which implements a protection mechanism as described above may not schedule the application program 152 within this amount of time. When this happens, the application program 152 does not receive the requested data.